/****************************************************
          File Name:7-7.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 20 Dec 2014 11:15:20 AM CST
*****************************************************/

#include<iostream>
using namespace std;

// same as 7-6

double *fill_array(double *a, int end)
{
    int i = 0;
    cout << "Enter a number: ";
    while(i < end && cin >> a[i])
    {
        cout << "Enter a number: ";
        i++;
    }

    return &a[i];
}

void show_array(double *a, double *end)
{
    int i;

    cout << endl;
    for(i = 0; i < end - a; i++)
        cout << a[i] << " ";
    cout << endl;
}

void reverse(double *a, double *end)
{
    double tmp;
    int i;
    int len = end - a - 2;
    for(i = 1; i < len; i++)
    {
        tmp = a[len];
        a[len] = a[i];
        a[i] = tmp;
    }
}

int main()
{
    double a[10];
    double *end = NULL;

    end = fill_array(a, 10);
    show_array(a, end);

    reverse(a, end);
    show_array(a, end);

    return 0;
}
